<template>
  <div>
    <Card>
			<!-- 搜索部分 -->
			<Form :model="formItem" :label-width="80" class="myForm">
				<!-- <FormItem label="操作类型">
            <Select style="width:200px">
							<Option :value="1">实例操作</Option>
						</Select>
        </FormItem> -->
				<FormItem label="用户检索">
						<Select style="width:200px" v-model="people">
							<Option v-for="item in peopleList" :key="item.uid" :value="item.userName">{{item.userName}}</Option>
						</Select>
				</FormItem>
				<!-- <FormItem label="时间">
						<DatePicker type="date" placeholder="起始时间" style="width: 200px" @on-change="getStartTime"></DatePicker>
						——
						<DatePicker type="date" placeholder="结束时间" style="width: 200px" @on-change="getEndTime"></DatePicker>
				</FormItem> -->
				<FormItem>
            <Button type="primary" @click="search()" class="large" style="padding:0 40px">搜索</Button>
						<Button type="primary" @click="rset()" class="large" style="padding:0 40px">刷新</Button>
        </FormItem>
			</Form>
			<!-- 搜索部分结束 -->
			<!-- 工单列表 -->
			<Table :columns="columns" :data="tableData"></Table>
			<div class="center">
				<div class="pageBox">
					<Page :total="count" show-total :page-size ="pageSize" @on-change="handlePage" :current="page"/>
				</div>
			</div>
			<Modal v-model="show" title="操作日志">
				{{text}}
			</Modal>
    </Card>
  </div>
</template>

<script>
export default {
  data () {
    return {
			// 列表头部配置
      columns: [
        {
					title: '操作人员',
					key: 'userName'
				},
				{
					title: '操作类型',
					key: 'type',
					render: (h, params) => {
						var typeVal = ''
						if (params.row.type === '1') {
							typeVal = '查询'
						}
						return h('span', typeVal)
					}
				},
				{
					title: '所做操作',
					key: 'description'
				},
				{
					title: '操作时间',
					key: 'actionDate',
					render: (h, params) => {
						var date1 = new Date(params.row.actionDate).toString().replace(/-/g, '/')
						var date2 = new Date(+new Date(date1) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/,
							'')
						return h('span', date2)
					}
				}
      ],
      tableData: [],
			show: false,
			count: 0,
			pageSize: 5,
			page: 1,
			formItem: {
				workcode: '',
				keyWork: ''
			},
			startTime: '',
			endTime: '',
			text: '',
			peopleList: [],
			people: ''
			}
  },
  methods: {
		// 分页页码跳转
		handlePage (value) {
			this.page = value
			this.getList()
		},
		// 搜索
		search () {
			this.page = 1
			// this.$api.get(0, '/kuber/v2/systemLog/page?page=' + this.page + '&limit=' + this.pageSize + '&userName=' + this.people, {}, r => {
			// 	if (r.data.code === 0) {
			// 		this.tableData = r.data.data.data
			// 		this.count = r.data.data.total
			// 	}
			// })
			this.getList()
		},
		search1 () {
			this.$api.get(0, '/kuber/v2/systemLog/page?page=' + this.page + '&limit=' + this.pageSize + '&userName=' + this.people, {}, r => {
				if (r.data.code === 0) {
					this.tableData = r.data.data.data
					this.count = r.data.data.total
				}
			})
		},
		// 获取列表数据
		getList () {
			let str = ''
			if (this.people !== '') {
				str = '&userName=' + this.people
			}
			this.$api.get(0, '/kuber/v2/systemLog/page?page=' + this.page + '&limit=' + this.pageSize + str, {}, r => {
				if (r.data.code === 0) {
					this.tableData = r.data.data.data
					this.count = r.data.data.total
				}
			})
		},
		rset () {
			this.people = ''
			this.page = 1
			this.getList()
		},
		// 获取人员列表
		getPeople () {
			this.$api.get(0, '/usr/v2/user/list', {}, r => {
				if (r.data.code === 0) {
					this.peopleList = r.data.data
				}
			})
		}
  },
  mounted () {
		this.getList()
		this.getPeople()
  }
}
</script>

<style>
  ul.ivu-page{
		margin-top:20px
	}
	table{
		width:100%!important
	}
	.myForm .ivu-form-item{
		display:inline-block;
	}
	.myForm .ivu-input{
		width:200px
	}
	.myForm .ivu-input-wrapper{
		width:auto
	}
</style>
